
# =====================================
# solve error：UnicodeEncodeError: 'gbk' codec can't encode character '\xXX' in position XX
# =====================================
import io
import sys
sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='gb18030') #改变标准输出的默认编码


from urllib import request

url = 'https://www.zhihu.com/hot'

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36',
    # plan A
    'cookie':'_zap=1292f7b5-fc3c-4ca9-9fde-535185b6aaed; d_c0="AABduzszwxGPTr_NxilUxapDTP2QQPidTdg=|1597937435"; _ga=GA1.2.1772810783.1597937436; __snaker__id=3kMKHx7KYDEjnFef; _9755xjdesxxd_=32; YD00517437729195%3AWM_NI=4RP4jbJo57O08BnkPOrxHF0DA7pAvOlbZuDZoT57Z3JXYlztAhvSkOHj125jql2bdZXiGFPVenKSdWaK1gooXiSlUY1u%2BB%2BldfDLmROZ7wdurm2QvQrbY%2BCfXPgWssIEU2E%3D; YD00517437729195%3AWM_NIKE=9ca17ae2e6ffcda170e2e6eea6b661a8b0add5d96bb78e8fa2d55e829f9fbbf53c89b58ad1c780aa978b8bc72af0fea7c3b92af88ea0d5e96a8ab1fbd8ce3cfc9ea28cd345b2a888a7b35083e9c0a2f545b0be9696c752ad8cfbd8d9398a88978df98083b8bab4ea458cb6ffd3b862b3b4fe83e7529cb789a7d35ea7b285b4e75da395ff88ee659cb79d8dd853f3abe5a3aa68a8ba8cadf05a8d86f998e77fb2b3feb2f55bb2be97ccc26e9c90a9b8f2798b9b9bd3c837e2a3; YD00517437729195%3AWM_TID=CtRVWqTTlUdAFFFQUBI7wLxBwS4nZRzC; _xsrf=2i6UeDwXf3oVg554HXF5UHpbJXkfi5Cb; captcha_session_v2="2|1:0|10:1618717254|18:captcha_session_v2|88:Nko3cXhhQmZqYnRRV2diNXBSSCt2RVYvK01CdlJLS0JtdE92bzZDbkxrRlJKSVQ5Ykxmd3RURTQwcWlYamRLYg==|438383ed61daf8b2bd64423ce21ddf2214e884c20ea292fdfc53064616f29138"; gdxidpyhxdE=L8hp9f9fctjfdLhLreHXq%2FAMbg6XyqZvn3GgyprLXsf198LQtU6rzppWMnhP%5CBdvqsn%2Bv11O5JCcP6VG0hBDtSI9ZtrkTo6LZSvOq439H%2FkTV%2FIO5W%2FuWsJV%2BgRu2U784BpecaEdYD0A8EJ7IQXz2D05yDZBnXGpEWbPeEmXwzkETaDN%3A1618718154210; captcha_ticket_v2="2|1:0|10:1618717266|17:captcha_ticket_v2|704:eyJ2YWxpZGF0ZSI6IkNOMzFfUVR2VGVaTDJVWlRoVm1JZ0RSVEt5OW81MVlDZU94VFpIQWxvbG1BUUpIdmZZajEwVk43RmJya1h5TFY2UVhxSklrMmFERzllVnQ5YnEyaHpOVlJKQjl2cml3V1hCLVRTeXR6YjFrcDgyRm96emw4ZXR5T1hiMmMtMVJPYlB2UFg3RHpMZWNRRzdMRlZSdjRWeW1BYkl6UU5kWU1CdkpMUmQyLm5qR1ZLaTFRUFdDQXpLLmt6VzZ4RUZVaUFSQXFNSXV1eGlMNjBrQ0dvSklsenowN2xrV1Y3MkdwOEtXYS4tMTFWZkNuR19JOXlEN21hS1BXVHVock1rMFR5TlFuMEQuQ1NJMkVLcW9Ld2xrREc0ZkwwRlRHN001bndmek9IdDU1ckpNcFRLNWF3eEs3MTRCc2RReV8wTEJFUXM1bXdualpYR19lOXdqX0VCOGc3dFRWeUpoMjF3TW5Bc3pncEtVMHdITC53UUZUeVBCbmY4Z0xZckc2ZlJvRjJnQThRS1h5THhaUVBVVXRQb2VTODFleW5VSlNESHgwWjhUd0FwLkMybjU0MTdYXzhMN2lPYm01bi56WXZUU2ZHZ3d1T2stWVZPbVphczk0LkhJanAtMF9sUEhXZjRnN3lfSzdFdjVSYV9WaDVYT0hJVEg4Tzk2VGt5NXFnUy1JMyJ9|ea794316923fc981d117406e894c878964c242a1d31abcf1f5a1deb64b24435c"; z_c0="2|1:0|10:1618717266|4:z_c0|92:Mi4xYm9wNEFnQUFBQUFBQUYyN096UERFU1lBQUFCZ0FsVk5VdmhvWVFEclgzcDRTZ3gxVm1OLWI5YzRMQXI1VHFYS1dB|eddca9f748e07e98350d67fe6605725625383c543439f999f7bf27a1e1f6d67b"; Hm_lvt_98beee57fd2ef70ccdd5ca52b9740c49=1618674668,1618717253,1618751162,1618752017; SESSIONID=UwQerdSEYkEge4gijyJVgpTCQJoSttDNOzwMGm3HRPP; JOID=VFsTAkzwRoukgsNGHfcCFVa-94EMoDTdx_GiEF-oKMvE4fYkceR29sOGw0QcaSZM0IUZi6-UOTMohuEX1ZCSIsI=; osd=VlkTB07yRIuhgMFEHfIAF1S-8oMOojTYxfOgEFqqKsnE5PQmc-Rz9MGEw0EeayRM1Ycbia-ROzEqhuQV15KSJ8A=; tst=h; tshl=; Hm_lpvt_98beee57fd2ef70ccdd5ca52b9740c49=1618752217; KLBRSID=81978cf28cf03c58e07f705c156aa833|1618752219|1618751163'
}

rq = request.Request(url, headers=headers)
resp = request.urlopen(rq)

print(resp.read().decode())